package com.example.jurisdiction.Controller;

import java.util.List;

import com.example.jurisdiction.Service.jurisdictionService;
import entity.jurisdiction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@CrossOrigin(methods = {RequestMethod.POST,RequestMethod.GET})
@Controller
@RequestMapping("/jurisdiction")
public class jurisdictionContoller {
	@Autowired
	private com.example.jurisdiction.Service.jurisdictionService jurisdictionService;
	
	
//	����û�
	@ResponseBody
	@RequestMapping("/addUser.do")
	public int add(@RequestBody jurisdiction j) throws Exception {
			System.out.println(j.getName());
			System.out.println(j.getDescn());
			System.out.println(j.getLink_url());
			System.out.println(j.getParent_id());
		return this.jurisdictionService.addjurisdiction(j);
	}
//	ɾ���û�
	@ResponseBody
	@RequestMapping("/delUser.do")
	public int del(Integer id) throws Exception {
			
		return this.jurisdictionService.deljurisdiction(id);
	}
//���ݱ�Ż�ȡָ���û�
	@RequestMapping("/getUser.do")
	public @ResponseBody jurisdiction get(Integer id) throws Exception{
		return this.jurisdictionService.getjurisdiction(id);
	}
//	�޸��û�
	@ResponseBody
	@RequestMapping("/updateUser.do")
	public int updateUser(@RequestBody jurisdiction j)throws Exception{
		System.out.println(j.getName());
		System.out.println(j.getDescn());
		System.out.println(j.getLink_url());
		System.out.println(j.getParent_id());
		return this.jurisdictionService.updatejurisdiction(j);
		
	}
	
	@RequestMapping("/select.do")
	public @ResponseBody List<jurisdiction> select() throws Exception{
		return this.jurisdictionService.select();
	}
}
